package com.ysg.binding.viewadapter;

import androidx.databinding.BindingAdapter;
import com.ysg.binding.command.BindingCommand;
import com.ysg.widget.title.YTitleBar;

public class TitleBarViewAdapter {

    @BindingAdapter(value = {"onLeftClickCommand", "onTitleClickCommand", "onRightClickCommand"}, requireAll = false)
    public static void setTitleClick(YTitleBar titleBar, final BindingCommand onLeftClickCommand, final BindingCommand onTitleClickCommand, final BindingCommand onRightClickCommand) {
        titleBar.setOnTitleBarListener(new YTitleBar.OnTitleBarListener() {

            @Override
            public void onLeftClick() {
                if (onLeftClickCommand != null) onLeftClickCommand.execute();
            }

            @Override
            public void onTitleClick() {
                if (onTitleClickCommand != null) onTitleClickCommand.execute();
            }

            @Override
            public void onRightClick() {
                if (onRightClickCommand != null) onRightClickCommand.execute();
            }
        });
    }


}
